package 数据库和网络;

import java.io.*;
import java.net.Socket;

public class userSocket{
    static final int PORT=20222;
    static final String HOST="10.27.203.166";
    Socket mySocket;
    BufferedReader infoReceiver;
    BufferedWriter commandSender;
    PrintWriter waiter;


    public void connection(){
        try {
            mySocket=new Socket(HOST,PORT);
            infoReceiver=new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
            commandSender=new BufferedWriter(new OutputStreamWriter(mySocket.getOutputStream()));
            waiter=new PrintWriter(commandSender,true);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void close(){
        try {
            this.waiter.close();
            this.commandSender.close();
            this.infoReceiver.close();
            this.mySocket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
